import java.util.Scanner;


public class Main {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        String str=in.next();
        char[] ch=str.toCharArray();
        StringBuilder s=new StringBuilder();
        for(int i=0;i<ch.length;i++){
            if(s.length()!=0&&s.charAt(s.length()-1)==ch[i]){
                s.deleteCharAt(s.length()-1);
            }else{
                s.append(ch[i]);
            }
        }
        System.out.println(s.length()==0?0:s.toString());
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt();
        int[] cost=new int[n];
        for(int i=0;i<n;i++){
            cost[i]=in.nextInt();
        }
        int[] dp=new int[n+1];
        for(int i=2;i<=n;i++){
            dp[i]=Math.min(dp[i-1]+cost[i-1],dp[i-2]+cost[i-2]);
        }
        System.out.println(dp[n]);
    }
}